package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsRoleMapper;
import com.qf.pojo.DtsRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * projectName: wokepase1
 *
 * @author: 强力
 * time: 2021/9/11 15:18
 * description:
 */
@Service
public class RoleServiceImpl implements RoleService{
    @Autowired
    private DtsRoleMapper roleMapper;

    @Override
    public Set<String> queryRoles(Integer[] ids) {
        Set<String> role=new HashSet<>();
        QueryWrapper<DtsRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("id",ids);
        List<DtsRole> list = roleMapper.selectList(queryWrapper);
        if (list != null) {
            for (DtsRole dtsRole : list) {
                role.add(dtsRole.getName());
            }

        }
        return role;
    }

    @Override
    public List<DtsRole> findAll() {
        QueryWrapper<DtsRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deleted",0);
        List<DtsRole> roleList = roleMapper.selectList(queryWrapper);
        return roleList;
    }
}
